<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title><?php echo $this->layout['meta_title'];?></title>
        <link rel="shortcut icon" type="/image/png" href="/img/ico.png"/>
        <link rel="icon" type="/image/png" href="/img/ico.png"/>
        <link rel="apple-touch-icon" href="/img/ico.png" />
        <link rel="stylesheet" href="/css/styles.css" type="text/css" />
        <link rel="stylesheet" href="/css/custom.css" type="text/css" />
        <script type="text/javascript" SRC="/js/jquery-1.4.2.min.js"></script>
        <script type="text/javascript" SRC="/js/jquery.ui.widget.min.js"></script>
        <script type="text/javascript" SRC="/js/jquery.ui.tabs.min.js"></script>
        <!-- jQuery tooltips -->
        <script type="text/javascript" SRC="/js/jquery.tipTip.min.js"></script>
        <!-- Superfish navigation -->
        <script type="text/javascript" SRC="/js/jquery.superfish.min.js"></script>
        <script type="text/javascript" SRC="/js/jquery.supersubs.min.js"></script>
        <!-- jQuery form validation -->
        <script type="text/javascript" SRC="/js/jquery.validate_pack.js"></script>
        <!-- jQuery popup box -->
        <script type="text/javascript" SRC="/js/jquery.nyroModal.pack.js"></script>        
    </head>
    
    
<body>


<style>
div#top {
	position: static;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
	
	/* setup navigation, content boxes, etc... */
	Administry.setup();
	/* 定义账号验证规则 */
	jQuery.validator.addMethod("usernameReg", function(value, element) { 
		var reg = /^[a-zA-Z0-9-_.]{3,32}$/;
		if(reg.test(value)){
			return true;
		}else{
			return false;
		}
		}, "只能由数字、字母、下划线组成，3-32个字符");

	// validate signup form on keyup and submit
	var validator = $("#loginform").validate({
		rules: {
			username: {
				required:true,
				usernameReg:true
			},
			password: "required"
		},
		messages: {
			username: {
				required:"请输入您的账号"
			},
			password: "请输入您的密码"
		},
		// the errorPlacement has to take the layout into account
		errorPlacement: function(error, element) {
			error.insertAfter(element.parent().find('label:first'));
		},
		// set new class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("ok");
		},
		submitHandler: function() {
			login();
		}

	});
});
function change_captcha()
{
     var codeurl = 'captcha?r=' + Math.ceil(Math.random() * 10000);
     $('#imgauth_reg').get(0).src = codeurl;
     $('#captcha').get(0).focus(); 
} 
function messageBox(info,type){
	var classInfo = '';
	if (type=='error')
	{
		classInfo = 'box box-error';
	}
	$('#box-info').html(info);
	$('#box-info').attr('class',classInfo);
}
function login(){
	var type	 = $('#type').val();
	var username = $('#username').val();
	var captcha = $('#captcha').val();
        var password = $('#password').val();
	$.post(
			'/admin_login/logins',
			{username: username, captcha: captcha,password:password},
			function (data){
				data = data.split(':');
				switch(data[0]){
					case '1':
						window.location = "index.php?m=admin&c=Admin_Manage&a=index";
						break;
					case '101':
                        change_captcha();
						messageBox(data[1],'error');
						break;                                             
					default:
                        change_captcha();
						messageBox('系统错误，请重新尝试','error');
						$('#username').select();
						break;
				}
			}
		);
}
</script>
</head>
<body>
	<!-- Header -->
	<div id="top">
		<div class="wrapper-login">
			<!-- Title/Logo - can use text instead of image -->
			<div id="title"></div>
		</div>
	</div>
	<!-- End of Header -->
	<!-- Page title -->
	<div id="pagetitle">
		<div class="wrapper-login"></div>
	</div>
	<!-- End of Page title -->
	
	<!-- Page content -->
	<div id="page">
		
		<!-- Wrapper -->
		<div class="wrapper-login">
				<!-- Login form -->
				<div class="full">					
					<?php echo $title; ?>
					<!--<h3>Login kefu.xoyo.com</h3>-->
					
					<div class="box box-info" id="box-info" style="margin-top:15px">用户登录</div>

					<form id="loginform" method="post" action="index.php/login/logins" onsubmit="return false;">

						<p>
							<label class="required" for="username">Username:</label><br/>
							<input type="text" id="username" class="yuangong_text" maxlength="32" name="username"/>
						</p>
						
						<p>
							<label class="required" for="password">Password:</label><br/>
							<input type="password" id="password" class="full" maxlength="32" name="password"/>
						</p>
                                                <p>
							<label class="required" for="Auth_code">Captcha:</label><br/>
							<input type="text" id="captcha" class="full" maxlength="5" name="Auth_code" style="width:12%;"/>
                            <img src="/captcha" id="imgauth_reg" onclick="change_captcha();"  title="看不清楚？点击换一张！" style="vertical-align: middle;"/>                                                
						</p>
						<p>
							<input type="submit" class="btn btn-green big" value="Login"/>
						</p>
						<div class="clear">&nbsp;</div>

					</form>
					
				</div>
				<!-- End of login form -->
				
			</div>
			<!-- End of Wrapper -->
	</div>
	<!-- End of Page content -->
	
	<!-- Page footer -->
	<div id="bottom">
		<div class="wrapper" style="text-align: center;">
			<p>Copyright &copy; 2012 XXXXXX-XXXXX | <b><a href="">XXXX</a></b></p>
		</div>
	</div>
</body>	
	<!-- End of Page footer -->
<script type="text/javascript" SRC="/js/administry.js"></script>